﻿//设置列表页面大小
function autoResize(options) {
    var defaults = {
        width: 6,
        height: 30
    };
    options = $.extend(defaults, options);

    // 第一次调用
    var wsize = getWidthAndHeigh();
    if ($.isFunction(options.callback)) {
        options.callback(wsize);
    }
    // 窗口大小改变的时候
    window.onresize = function() {
        var size = getWidthAndHeigh(true);
        //alert(size.height);
        $(options.dataGrid).datagrid({ height: size.height, width: wsize.width });
    };

    // 获取iframe大小
    function getWidthAndHeigh(resize) {
        var windowHeight = 0;
        var widowWidth = 0;
        if (typeof (window.innerHeight) == 'number') {
            windowHeight = window.innerHeight;
            widowWidth = window.innerWidth;
        }
        else {
            if (document.documentElement && document.documentElement.clientHeight) {
                windowHeight = document.documentElement.clientHeight;
                widowWidth = document.documentElement.clientWidth;
            } else {
                if (document.body && document.body.clientHeight) {
                    windowHeight = document.body.clientHeight;
                    widowWidth = document.body.clientWidth;
                }
            }
        }
        widowWidth -= options.width;
        windowHeight -= options.height;


        return { width: widowWidth, height: windowHeight + 21 };
    }
}
